<extend name="Public:base" />
<block name="title">病例记录</block>
<block name="content">
    <input type="hidden" name="page" id="page">
    <div class="page__bd">
        <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">疾病类型</label></div>
            <div class="weui-cell__bd sele_xial ">
                <select class="weui-select input_border " name="cateid" id="cateid">
                    <option value="0">请选择疾病类型</option>
                    <foreach name="catelist" item="vo">
                        <option value="{$vo['id']}">{$vo['title']}</option>
                    </foreach>
                </select>
            </div>
        </div>
        <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">起止时间</label></div>
            <div class="weui-cell__bd">
                <!---->
                <div class="weui-cell__bd">
                    <input class="weui-input center_riqi fl input_border" type="date" value="{$starttime}" name="starttime" id="starttime">
                    <input class="weui-input center_riqi fr input_border"  type="date" value="{$endtime}" name="endtime" id="endtime">
                </div>

            </div>
        </div>
        <div class="weui-cell xian_bottom">
            <input type="text" class="center_search input_border bingli_ser fl" placeholder="请输入患者名称" name="patientname" id="patientname"/>
            <a href="javascript:;" class="weui-btn weui-btn_mini  bingli_but " id="searchpatient">搜索</a>
        </div>
        <div class="page__bd">
            <div id="search_Result">
                <!--<div class="weui-form-preview__bd center_list_one">
                    <div class="weui-form-preview__item">
                        <label class="weui-form-preview__label">患者姓名：</label>
                        <span class="weui-form-preview__value">张三</span>
                    </div>
                    <div class="weui-form-preview__item">
                        <label class="weui-form-preview__label">疾病类型：</label>
                        <span class="weui-form-preview__value">艾滋病</span>
                    </div>
                    <div class="weui-form-preview__item">
                        <label class="weui-form-preview__label">时间：</label>
                        <span class="weui-form-preview__value">2017.01.27</span>
                    </div>
                </div>-->
            </div>
            <div id="showmsg"></div>
            <input type="button" id="more" class="listmore" value="加载更多">
        </div>
    </div>
    <script type="text/javascript">
        var page = $("#page").val();
        if(!page){
            page = 1;
        }
        cateid      = $('#cateid').val();
        starttime   = $('#starttime').val();
        endtime     = $('#endtime').val();
        var patientname = $("#patientname").val();
        patient_list(page,cateid,starttime,endtime,patientname);
        $("#more").click(function(){
            var page = $("#page").val();
            var patientname = $("#patientname").val();
            patient_list(page,cateid,starttime,endtime,patientname);
        });
        $("#cateid").change(function(){
            cateid = $('#cateid').val();
            $("#search_Result").html('');
            var patientname = $("#patientname").val();
            $("#more").show();
            patient_list(1,cateid,starttime,endtime,patientname);
        });
        $("#searchpatient").click(function(){
            cateid      = $('#cateid').val();
            starttime   = $('#starttime').val();
            endtime     = $('#endtime').val();
            patientname = $('#patientname').val();
            $("#search_Result").html('');
            patient_list(page,cateid,starttime,endtime,patientname);
        });
        function patient_list(page,cateid,starttime,endtime,patientname){
            $.ajax({
                type:'post',
                url:'__MODULE__/User/patientlist',
                data:{page:page,cateid:cateid,starttime:starttime,endtime:endtime,patientname:patientname},
                cache:false,
                dataType:'json',
                success:function(res){
                    if (res.code == 0) {
                        var arr = res.data;
                        var str = '';
                        $.each(arr, function (i) {
                            str += '<a href="__MODULE__/User/patient_detail/id/' + this.id + '" class="weui-form-preview__bd center_list_one"><div class="weui-form-preview__item"><label class="weui-form-preview__label">患者姓名：</label><span class="weui-form-preview__value">' + this.name + '</span></div><div class="weui-form-preview__item"><label class="weui-form-preview__label">疾病类型：</label><span class="weui-form-preview__value">' + this.title + '</span> </div><div class="weui-form-preview__item"><label class="weui-form-preview__label">时间：</label><span class="weui-form-preview__value">' + this.addtime + '</span></div></a>';
                        });
                        $("#page").val(res.page);
                        $("#search_Result").append(str);
                    } else {
                        var str2 = '';
                        str2 += '<div class="nomore"><p>' + res.msg + '</p></div>';
                        $("#search_Result").append(str2);
                        $("#more").hide();
                    }
                }
            });
        }
    </script>
</block>